package io.github.jesse205.deskclock.lite.utils;

import android.content.Context;

import androidx.annotation.NonNull;

public final class DimensionUtil {
    private DimensionUtil() {
    }

    public static int dp2px(@NonNull Context context, float dpValue) {
        float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    public static int px2dp(@NonNull Context context, float pxValue) {
        float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }
}
